{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1393
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i, n, ans : longint;
	a, b : array[0..1010] of longint;
 
begin
	reset(input,'input.txt');
	rewrite(output,'output.txt');
	fillchar(b, sizeof(b), 0);
	read(n);
	for i := 1 to n do begin
		read(a[i]);
		inc(b[a[i]]);
	end;
	ans := 0;
	for i := 1 to n do
		if b[i] = i then inc(ans);
	if ans = 1 then write(0) else write(ans);
end.